package demo.base;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;

public class ClientHandler extends IoHandlerAdapter {
	private String msg;
	
	public ClientHandler(String msg) {
		this.msg = msg;
	}
	
	@Override
	public void sessionClosed(IoSession session) throws Exception {
		System.out.println("session close");
	}

	@Override
	public void sessionOpened(IoSession session) throws Exception {
		super.sessionOpened(session);
		session.write(msg);
	}
	
	@Override
	public void messageReceived(IoSession session, Object message) throws Exception {
		System.out.println("recv server : "+message.toString());
		session.close(false);
	}
}
